package it.tukano.treditor.engine.mesh;

import it.tukano.treditor.engine.geom.NSegment;
import it.tukano.treditor.engine.geom.NTriangle;
import it.tukano.treditor.engine.geom.NTuple3;
import java.util.Arrays;

public class Mesh3D {
    
    private final int triangleCount;
    private final NTriangle[] triangles;
    private final NTuple3 color;
    private final NSegment[] segments;
    private final int segmentCount;

    /**
     * Instance initializer
     */
    public Mesh3D(NTriangle[] triangles, NSegment[] segments, NTuple3 color) {
        this.triangles = triangles == null ? null : Arrays.<NTriangle>copyOf(triangles, triangles.length);
        this.triangleCount = triangles == null ? 0 : triangles.length;
        this.segments = segments == null ? null : Arrays.<NSegment>copyOf(segments, segments.length);
        this.segmentCount = segments == null ? 0 : segments.length;
        this.color = color;
    }
    
    public boolean hasColor() {
        return color != null;
    }

    public NTuple3 getColor() {
        return color;
    }
    
    public int getTriangleCount() {
        return triangleCount;
    }
    
    public NTriangle getTriangle(int index) {
        return triangles[index];
    }

    public int getSegmentCount() {
        return segmentCount;
    }
    
    public NSegment getSegment(int index) {
        return segments[index];
    }
}
